#include "FrontendState.h"


FrontendState::FrontendState(GameContext& gc):GameState(gc)
{
}


FrontendState::~FrontendState(void)
{
}

 void FrontendState::Load()
 {
	mFont.Load(20);
	mCursor.Load("sword.png");

	mStartButton1.Load("button_on.png", "button_off.png");
	mStartButton1.SetPosition(SVector2(200.0f, 500.0f));
	mStartButton1.SetText("Level1", 255, 255, 255);

	mStartButton2.Load("button_on.png", "button_off.png");
	mStartButton2.SetPosition(SVector2(200.0f, 550.0f));
	mStartButton2.SetText("Level2", 255, 255, 255);

	mQuitButton.Load("button_on.png", "button_off.png");
	mQuitButton.SetPosition(SVector2(200.0f, 600.0f));
	mQuitButton.SetText("Quit", 255, 255, 255);
 }

 void FrontendState::Unload()
 {
	 mFont.Unload();
	 mCursor.Unload();
	 mStartButton1.Unload();
	 mStartButton2.Unload();
	 mQuitButton.Unload();
 }

NextState FrontendState::Update(float deltaTime)
 {
	
	 mCursor.Update(deltaTime);
	 mStartButton1.Update(deltaTime);
	 mStartButton2.Update(deltaTime);
	 mQuitButton.Update(deltaTime);

	 NextState nextState = None;
	 if (mStartButton1.IsPressed())
	 {
		 mGameContext.setLevel(1);
		 nextState = Gameplay;
	 }
	 else if (mStartButton2.IsPressed())
	 {
		  mGameContext.setLevel(2);
		 nextState = Gameplay;
	 }
	 else if (mQuitButton.IsPressed())
	 {
		 nextState = Quit;
	 }

	 return nextState;
 }

 void FrontendState::Render()
 {
	 mFont.Print("pikachu",100,200);
	 mStartButton1.Render();
	 mStartButton2.Render();
	 mQuitButton.Render();
	 mCursor.Render();
 }
